package com.asteros.crypto;

import com.asteros.crypto.config.AppConfig;
import com.asteros.crypto.utils.content.ContentManager;
import com.asteros.crypto.utils.content.RemoteCM_servlet;
import com.asteros.crypto.utils.content.RemoteCM_ws;
import com.asteros.crypto.utils.services.CryptoService;
import com.asteros.crypto.utils.services.CryptoServiceConfig;

public final class ServiceFactory
{
	private static ServiceFactory instance = new ServiceFactory();

	public static ServiceFactory getInstance()
	{
		return instance;
	}

	public CryptoService createCryptoService(CryptoServiceConfig config) throws Exception {
		return new CryptoService(config);
	}

	public RemoteClient createRemoteClient() throws Exception
	{
		return this.createRemoteClient(AppConfig.getInstance().getRutokenCryptoServiceConfig());
		//		return new RemoteClient(AppConfig.getInstance().getRutokenCryptoServiceConfig(), new RemoteCM_servlet());
	}
	public RemoteClient createRemoteClient(CryptoServiceConfig config) throws Exception {
		System.out.println("ServiceFactory.createRemoteClient>>");
		//		return new RemoteClient(config, new RemoteCM_servlet());
		RemoteClient rc = new RemoteClient(config, new RemoteCM_ws());
		System.out.println("ServiceFactory.createRemoteClient>>");
		return rc;
	}

	public ServerClient createServerClient(CryptoServiceConfig config, ContentManager cMan) throws Exception
	{
		return new ServerClient(config, cMan);
	}
}
